#
# @lc app=leetcode.cn id=53 lang=python3
#
# [53] 最大子序和
#

# @lc code=start
class Solution:
    def maxSubArray(self, nums: List[int]) -> int:
        if len(nums) == 1:
            return nums[0]
        else:  
            sum = nums[0]
            n = nums[0]
            for i in range(1,len(nums)):
                n = n + nums[i] if n > 0 else nums[i]
                sum = n if n > sum else sum
            return sum
# @lc code=end

